import Taro from '@tarojs/taro'

export function setCache (key, val) {
  let params
  if(typeof val == 'object') {
    params = JSON.stringify(val)
  }

  Taro.setStorageSync(key, params)
}

export function getCache (key) {
  let res = Taro.getStorageSync(key)
  if(res) {
    res = JSON.parse(res)
  }else{
    return null
  }
  return res
}